


//阅读一篇帖子页面
let postId=window.location.search.split('=')[1]
let box=document.querySelector('.box')
function tiziMessage(){


    axios({
        url:'/tieziMessage',
        method:'get',
        params:{
            postId:postId
        }
    }).then(data=>{
        console.log(data);
       let message=data.data.data.data
    
let pic=message.path.split('[')[1].split(']')[0]
   
      
       box.innerHTML=` <span class="bigpic"><img src='${pic}'></span>
       <span class="bigright"><span class='head'><img src='${message.portrait}'></span>
       <span class='username'>${message.userName}</span>
       <span class='context'>${message.context}</span><span class='time'>${message.time}</span></span>
       <div class="last">
       <span><i class="fa fa-thumbs-o-up"></i>${message.thumbUpCount}</span>
       <span><i class="fa fa-heart-o"></i>${message.collectCount}</span>
       <span><i class="fa fa-eye"></i>${message.visit}</span>
       <span>
       <button class='delete'  onclick='condelete()'>删除</button></span>
</div>`
     
       
    }).catch(err=>{
        console.log(err);
        alert('noi')
    })
}
tiziMessage()


//确认框
condelete=function(){
    if(confirm('确定删除该帖子吗？')==true){
        dttiezi()
       }else{
        return false
    }
}

//删除帖子
dttiezi=function(){
axios({
            method: 'post',
            url: '/dttiezi',
            params: {
                postId:postId
            }
        }).then(data => {
         if(data.data.data.message='成功'){
             alert('已成功删除！')
           box.innerHTML=`<span class='gai'>暂时没有帖子</span>`
window.location.href='http://localhost:8081/picture/picture'
tiziMessage()
           
         }else{
             alert('帖子删除失败')
         }
       
        }).catch(err => {
            console.log(err);
            alert('no')
        })
    }
    

  
